#ifndef GEOMETRYUTILITIES_H
#define GEOMETRYUTILITIES_H

#include "point.h"
#include "line.h"
#include "ray.h"
#include "linesegment.h"
#include "circle.h"
#include <QRect>

// This namespace handles the different interactions with the different geomety
// utilities classes that would otherwise cause cyclic dependicies.
namespace GeometryUtilities
{
  enum IntersectionInfo {NO_INTERSECTION=0, INTERSECTION, PARALLEL, COINCIDENT, CONTAINED};
  Point LineLineIntersect(const Line& l1, const Line& l2, IntersectionInfo& info);
  Point LineRayIntersect(const Line& l, const Ray& r, IntersectionInfo& info);
  Point RayLineIntersect(const Ray& r, const Line& l, IntersectionInfo& info);
  Point LineLineSegmentIntersect(const Line &l, const LineSegment& ls, IntersectionInfo& info);
  Point LineSegmentLineIntersect(const LineSegment &ls, const Line& l, IntersectionInfo& info);

  Point RayRayIntersect(const Ray& r1, const Ray& r2, IntersectionInfo& info);
  Point RayLineSegmentIntersect(const Ray &r, const LineSegment& ls, IntersectionInfo& info);
  Point LineSegmentRayIntersect(const LineSegment& ls, const Ray& r, IntersectionInfo& info);

  Point LineSegmentLineSegmentIntersect(const LineSegment& ls1, const LineSegment& ls2, IntersectionInfo& info);

  void CircleCircleIntersect(const Circle& c1, const Circle& c2, Point (&pts)[2], IntersectionInfo& info);

  // Axis-aligned Bounding Box (AABB)
  void RayRectIntersect(const Ray &r, const QRect &rect, Point (&pts)[2], IntersectionInfo& info);
}

#endif // GEOMETRYUTILITIES_H
